import { Component, OnInit } from '@angular/core';

@Component({
  selector: 'app-mall',
  templateUrl: './mall.page.html',
  styleUrls: ['./mall.page.less'],
})
export class MallPage implements OnInit {

  constructor() { }

  ngOnInit() {
  }

  imgList = [
    {img: 'product1.png', imgName: '园艺用品'},
    {img: 'product1.png', imgName: '园艺用品'},
    {img: 'product1.png', imgName: '园艺用品'},
    {img: 'product1.png', imgName: '园艺用品'},
    {img: 'product1.png', imgName: '园艺用品'},
    {img: 'product1.png', imgName: '园艺用品'},
    {img: 'product1.png', imgName: '园艺用品'},
    {img: 'product1.png', imgName: '园艺用品'},
    {img: 'product1.png', imgName: '园艺用品'},
    {img: 'product1.png', imgName: '园艺用品'},
  ];

  detailMethod(detail): any {
    let array;
    array = Array.from(new Array(detail.length)).map((_val, i) => ({
      icon: 'assets/src/img/'+detail[i].img,
      text: detail[i].imgName
    }));
    return array;
  }

  click(event) {
    console.log(event);
  }

  sortList = [
    {
      name: '推荐',
      description: '热门分类',
      detail: this.detailMethod(this.imgList)
    }, {
      name: '百货',
      description: '本周热门',
      detail: this.detailMethod(this.imgList)
    }, {
      name: '家纺',
      description: '本周热门',
      detail: this.detailMethod(this.imgList)
    }, {
      name: '手机',
      description: '本周热门',
      detail: this.detailMethod(this.imgList)
    }, {
      name: '女装',
      description: '本周热门',
      detail: this.detailMethod(this.imgList)
    }, {
      name: '食品',
      description: '本周热门',
      detail: this.detailMethod(this.imgList)
    }, {
      name: '男装',
      description: '本周热门',
      detail: this.detailMethod(this.imgList)
    }, {
      name: '鞋包',
      description: '本周热门',
      detail: this.detailMethod(this.imgList)
    }, {
      name: '母婴',
      description: '本周热门',
      detail: this.detailMethod(this.imgList)
    }, {
      name: '电器',
      description: '本周热门',
      detail: this.detailMethod(this.imgList)
    }, {
      name: '内衣',
      description: '本周热门',
      detail: this.detailMethod(this.imgList)
    }, {
      name: '美妆',
      description: '本周热门',
      detail: this.detailMethod(this.imgList)
    }, {
      name: '健康',
      description: '本周热门',
      detail: this.detailMethod(this.imgList)
    }, {
      name: '洗护',
      description: '本周热门',
      detail: this.detailMethod(this.imgList)
    }
  ];

  index = 0;

  onChange(item) {
    console.log('onChange', item);
  }

  onTabClick(item) {
    console.log('onTabClick', item);
  }
}
